package com.jieshuibao.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.jieshuibao.mapper.CompanyMapper;
import com.jieshuibao.mapper.UserMapper;
import com.jieshuibao.model.db.Company;
import com.jieshuibao.model.db.CompanyExample;
import com.jieshuibao.model.db.User;

@Service
public class CompanyService{
	
	@Resource
	private CompanyMapper companyMapper;
	@Resource
	private UserMapper userMapper;
	
	public void addCompany(Company company) {
		companyMapper.insertSelective(company);
	}
	
	public void delCompanyByUuid(String uuid) {
		companyMapper.deleteByPrimaryKey(uuid);
	}
	
	public void updateCompany(Company company) {
		companyMapper.updateByPrimaryKeySelective(company);
	}
	
	public Company getCompanyByUuid(String uuid) {
		return companyMapper.selectByPrimaryKey(uuid);
	}
	
	public List<Company> getPageCompany(CompanyExample companyExample) {
		return companyMapper.selectPage(companyExample);
	}
	
	public int countCompany(CompanyExample companyExample) {
		return companyMapper.countByExample(companyExample);
	}
	public void uodateUserAndAddCompany(User user,Company company){
		if(user!=null){
			userMapper.updateByPrimaryKeySelective(user);
		}
		if(company!=null){
			companyMapper.insertSelective(company);
			
		}
		
	}
}
